void setup(){
  size(720, 480);
  noStroke();
  smooth();
    
  // Sky
  setGradient(0, 0, width, height, color(#000000), color(#0034A0));
  
  int ground = height*3/5;
  // Mountains
  float mX = 0.0;
  float mInc = 0.0075;
  for (int x=0; x<width; x++){
    int mY = (int)(noise(mX) * ground);
    for(int y=mY; y<ground; y++){
      set(x, y, color(#000000));;
    }
    mX += mInc;
  }
  
  // Trees
  noStroke();
  fill(color(#204800));
  int treeWidth = 10;
  mX = 0.0;
  mInc = 0.07;
  for (int x=0; x<=width; x+=treeWidth){
    int mY = ground - (int)(noise(mX) * 40) - 10;
    triangle(x - treeWidth, ground,
    x, mY, x + treeWidth, ground);
    mX += mInc;
  }
}

void draw() {

}

void setGradient(int x, int y, float w, float h, color c1, color c2){
  // calculate differences between color components 
  float deltaR = red(c2)-red(c1);
  float deltaG = green(c2)-green(c1);
  float deltaB = blue(c2)-blue(c1);

  loadPixels();
  for (int i=x; i<x+w; i++){
    for (int j=y; j<y+h; j++){
      color c = color(
      (red(c1)+(j-y)*(deltaR/h)),
      (green(c1)+(j-y)*(deltaG/h)),
      (blue(c1)+(j-y)*(deltaB/h)) 
        );
      pixels[j*width+i] = c;
    }
  }
  updatePixels();
}
